182B - Vasya's Calendar - CodeForces Solution


implementation *1000

Please click on ads to support us..

Python Code:

d = int(input())
n = int(input())
przhm = list(map(int, input().split()))
slv = dict()
amn = 0

for i in range (len(przhm) - 1):
    if przhm[i] == d:
        continue
    if przhm[i] not in slv:
        slv[przhm[i]] = 1
    else:
        slv[przhm[i]] += 1
        
sps = slv.items()

for j in sps:
    n_d = j[0] * j[1]
    d_d = d * j[1]
    amn = amn + (d_d - n_d)
    
print (amn)

C++ Code:

#include <bits/stdc++.h>

#define _freopen_in freopen("input.txt", "r", stdin)
#define _freopen_out freopen("output.txt", "w", stdout)
#define _fast_io ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define _cin_ignore cin.ignore(numeric_limits<streamsize>::max(), '\n')
#define _iterator(container) container.begin(), container.end()
#define _str(x) to_string((x))
#define _len(x) int(size((x)))
#define _max(x, y, z) max((x), max((y), (z)))
#define _min(x, y, z) min((x), min((y), (z)))
#define _print_list(list) for (auto x : list) { cout << x << " "; } cout << '\n'
#define _print_grid(grid) for (const auto& v : grid) { for (auto x : v) { cout << x << " "; } cout << '\n'; }
#define _print_map(mp) for (const auto& [ k, v ] : mp) { cout << k << ": " << v << endline; }
#define _lcm(x, y) (((x) * (y)) / __gcd((x), (y)))
#define _index_of(list, x) find(list.begin(), list.end(), (x)) - list.begin()
#define _sublist(list, x, y) decltype(list)(list.begin() + x, list.begin() + y + 1)
#define endline '\n'
#define MULTI_LINE(...) #__VA_ARGS__

constexpr long double PI = 3.14159265358979323846;
constexpr long long int MOD = (long long int)1e9 + 7;
constexpr long double eps = 5e-8;

using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;

void run(int tc)
{
	int d, n;
	cin >> d >> n;

	int total = 0;
	vector<int> a(n);
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}

    for (int i = 0; i < n - 1; i++)
    {
        total += d - a[i];
    }

	cout << total << endline;
}

/**
 * Problem Name: 
 * Problem URL: 
 * References 1: 
 *
 * Solution Time Complexity: 
 * Solution Space Complexity: 
 *
 * @author zeus
 */
int main()
{
    _fast_io;
    // _freopen_in;

    int t = 1;
    // cin >> t;

    for (int i = 1; i <= t; i++)
    {
        // cout << "test case: " << i << endline;
        run(i);
    }

    return 0;
}


Comments

Submit
0 Comments
More Questions

1605B - Reverse Sort
1607C - Minimum Extraction
1604B - XOR Specia-LIS-t
1606B - Update Files
1598B - Groups
1602B - Divine Array
1594B - Special Numbers
1614A - Divan and a Store
2085. Count Common Words With One Occurrence
2089. Find Target Indices After Sorting Array
2090. K Radius Subarray Averages
2091. Removing Minimum and Maximum From Array
6. Zigzag Conversion
1612B - Special Permutation
1481. Least Number of Unique Integers after K Removals
1035. Uncrossed Lines
328. Odd Even Linked List
1219. Path with Maximum Gold
1268. Search Suggestions System
841. Keys and Rooms
152. Maximum Product Subarray
337. House Robber III
869. Reordered Power of 2
1593C - Save More Mice
1217. Minimum Cost to Move Chips to The Same Position
347. Top K Frequent Elements
1503. Last Moment Before All Ants Fall Out of a Plank
430. Flatten a Multilevel Doubly Linked List
1290. Convert Binary Number in a Linked List to Integer
1525. Number of Good Ways to Split a String